package com.founder.android.reader.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.founder.android.reader.R;
import com.founder.android.reader.bean.ZipPicture;
import com.founder.android.reader.bookview.AbsAdapter;

public class BookImageAdapter<T> extends AbsAdapter<ZipPicture> {
	private Context mContext;
	private RelativeLayout.LayoutParams lp;
	public BookImageAdapter(Context context) {
		super();
		this.mContext = context;
		lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
		lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	}
	public void addItem(List<ZipPicture> list){
		super.list.addAll(list);
	}
	@Override
	public int getCount() {
		return super.list.size();
	}

	@Override
	public ZipPicture getItem(int position) {
		return super.list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position) {
		RelativeLayout rt = new RelativeLayout(mContext);
		rt.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
		rt.setBackgroundColor(Color.WHITE);
		rt.setBackgroundResource(R.drawable.ly);
		ImageView view = new ImageView(mContext);
		view.setImageBitmap(super.list.get(position).zipBitmap);
		rt.addView(view,lp);
		return rt;
	}

}
